<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <titlt> 幸运数字游戏</titlt>
    <style>
        .success {
            color: #f00;
        }

        .fail {
            color: #000;
        }
    </style>
    <script>
        var acnt = 0;
        var vcnt = 0;


        function GetRandomNum() {
            return (1 + Math.round(Math.random() * 8));
        }

        var a = 0, b = 0, c = 0, f = 0;

        function play() {
            acnt++;
            var result = "还得努力哦!";
            var resultStyle = "fail";
            a = GetRandomNum();
            b = GetRandomNum();
            c = GetRandomNum();
            if (a == 8 || b == 8 || c == 8) {
                vcnt++;
                result = "恭喜，您赢了!";
                resultStyle = "success";
            }
            f = ((vcnt / acnt) * 100).toFixed(2);
        }
    </script>
</head>


<body>
<script type="text/javascript">
    var d;
    d = confirm("确定要开始游戏了吗？");
    if (d == true) {
        var e = true;
        while (e) {
            play();
            e = confirm(a + ' ' + b + ' ' + c + '\n' + '你已经玩了' + acnt + '局，胜了' + vcnt + '局，胜率为' + f + '%');
        }
        alert("好好休息吧！");
    }
</script>
</body>
</html>